var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, i) {
    var a, o = arguments.length, s = o < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, n) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(t, e, n, i); else for (var r = t.length - 1; 0 <= r; r--) (a = t[r]) && (s = (o < 3 ? a(s) : 3 < o ? a(e, n, s) : a(e, n)) || s);
    return 3 < o && s && Object.defineProperty(e, n, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
}), n.BtnIconType = n.BtnBgType = void 0;

var r, s, c = e("Global"), l = e("AudioManager"), d = e("RecorderManager"), u = e("GameConfig"), p = e("LoadManager"), h = e("WebManager"), f = e("UIManager");

(function(t) {
    t[t.YELLOW = 0] = "YELLOW", t[t.GREEN = 1] = "GREEN", t[t.GRAY = 2] = "GRAY";
})(r = n.BtnBgType || (n.BtnBgType = {})), function(t) {
    t[t.VIDEO = 0] = "VIDEO", t[t.SHARE = 1] = "SHARE", t[t.RECORDER = 2] = "RECORDER", 
    t[t.NONE = 3] = "NONE", t[t.NORMAL = 4] = "NORMAL";
}(s = n.BtnIconType || (n.BtnIconType = {}));

var g = cc._decorator, m = g.ccclass, y = g.property, v = cc.Enum({
    YELLOW: 0,
    GREEN: 1,
    GRAY: 2
}), w = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.auto = !0, t.tag = "", t.viewname = "", t.btnname = "", t.btnStr = "", 
        t.btnBgType = r.YELLOW, t.btnIconType = s.VIDEO, t.bgSprite = null, t.iconSprite = null, 
        t.btnLabel = null, t.click = !1, t.btnBgYellowPath = "image/btn/btn_bg_yellow", 
        t.btnBgGreenPath = "image/btn/btn_bg_green", t.btnBgGrayPath = "image/btn/btn_bg_gray", 
        t;
    }
    return i(t, e), t.prototype.onClick = function(e) {
        var n = this;
        if (l.default.getInstance().playAudio("按钮2"), !this.click) switch (this.click = !0, 
        this.scheduleOnce(function() {
            n.click = !1;
        }, .5), this.btnIconType) {
          case s.SHARE:
            this.pushEvent("分享" + this.btnname), GA.rewardOperation({
                tag: this.tag,
                page: "",
                byVideo: !1,
                result: function(t) {
                    t.reward && cc.systemEvent.emit(n.tag, e);
                }
            });
            break;

          case s.VIDEO:
            if (GA.Info.underCheck && u.GC.isDebug) return cc.systemEvent.emit("videoEnd", this.tag), 
            void cc.systemEvent.emit(this.tag, e);
            this.pushEvent("视频" + this.btnname), GA.rewardOperation({
                tag: this.tag,
                page: "",
                byVideo: !0,
                result: function(t) {
                    t.reward && (cc.systemEvent.emit("videoEnd", n.tag), cc.systemEvent.emit(n.tag, e));
                }
            });
            break;

          case s.RECORDER:
            if (GA.Info.underCheck && u.GC.isDebug) return console.log("222", this.tag), void cc.systemEvent.emit(this.tag, e);
            d.default.getInstance().videoPath ? (cc.game.pause(), this.pushEvent("录屏" + this.btnname), 
            h.default.getInstance().sentLog("TryShareVideo"), GA.PA.shareAppMessage({
                channel: "video",
                title: "我就要吃鸡",
                desc: "进入吃鸡的世界",
                imageUrl: "",
                templateId: "3eld33adx4d3bk46j6",
                query: "krq_wjycj=10002",
                extra: {
                    videoPath: d.default.getInstance().videoPath,
                    videoTopics: [ "我就要吃鸡", "卡日曲游戏" ],
                    withVideoId: !0,
                    createChallenge: !1
                },
                success: function(t) {
                    cc.game.resume(), h.default.getInstance().sentLog("ShareVideoSuccess"), t.videoId && h.default.getInstance().saveVideoId({
                        aliasId: t.videoId,
                        success: function(t) {
                            console.log("保存视频成功:", t);
                        }
                    }), console.log("分享视频成功:", t), cc.systemEvent.emit(n.tag, e);
                },
                fail: function(t) {
                    cc.game.resume(), h.default.getInstance().sentLog("ShareVideoFailed"), "shareAppMessage:cancel" == t.errMsg || "shareAppMessage:fail video duration is too short" == t.errMsg && f.default.getInstance().showToast({
                        str: "抱歉,录屏时间太短！"
                    }), console.log("分享视频失败:", t);
                }
            })) : f.default.getInstance().showToast({
                str: "抱歉,无可分享录屏！"
            });
            break;

          case s.NORMAL:
            this.pushEvent(this.btnname), cc.systemEvent.emit(this.tag, e);
        }
    }, t.prototype.start = function() {
        c.G.platform == c.Platform.XiaoDu ? this.node.active = !1 : this.auto && this.init();
    }, t.prototype.init = function(t, e, n, i) {
        if (c.G.platform != c.Platform.XiaoDu) {
            if (t && this.tag != t && (this.tag = t), this.bgSprite) switch (-1 < n && (this.btnBgType = n), 
            this.bgSprite.type = cc.Sprite.Type.SLICED, this.bgSprite.sizeMode = cc.Sprite.SizeMode.CUSTOM, 
            this.btnBgType) {
              case r.YELLOW:
                p.default.getInstance().loadSpriteFrame({
                    url: this.btnBgYellowPath,
                    sprite: this.bgSprite
                });
                break;

              case r.GREEN:
                p.default.getInstance().loadSpriteFrame({
                    url: this.btnBgGreenPath,
                    sprite: this.bgSprite
                });
                break;

              case r.GRAY:
                p.default.getInstance().loadSpriteFrame({
                    url: this.btnBgGrayPath,
                    sprite: this.bgSprite
                });
            }
            if (this.btnLabel && (null != e && this.btnStr != e && (this.btnStr = e), this.node.height < 100 ? this.btnLabel.node.scale = this.node.height / 100 : this.btnLabel.node.scale = 1, 
            this.btnLabel.string = this.btnStr), GA.isPlatform(GA.Platform.Kwaigame) ? i == s.SHARE && (this.btnIconType = s.VIDEO) : i ? this.btnIconType = i : -1 < u.GC.btnIconType ? this.btnIconType = u.GC.btnIconType : this.btnIconType = GA.isNextRewardVideo(this.tag) ? s.VIDEO : GA.isByteDance() && d.default.getInstance().videoPath ? s.RECORDER : s.SHARE, 
            this.iconSprite) switch (this.node.height < 100 ? this.btnLabel.node.scale = this.node.height / 100 : this.btnLabel.node.scale = 1, 
            this.iconSprite.sizeMode = cc.Sprite.SizeMode.RAW, this.btnIconType) {
              case s.SHARE:
                p.default.getInstance().loadSpriteFrame({
                    url: "image/btn/btn_icon_share",
                    sprite: this.iconSprite
                });
                break;

              case s.VIDEO:
                p.default.getInstance().loadSpriteFrame({
                    url: GA.isPlatform(GA.Platform.ByteDance) ? "image/btn/btn_icon_video_2" : "image/btn/btn_icon_video",
                    sprite: this.iconSprite
                });
                break;

              case s.RECORDER:
                p.default.getInstance().loadSpriteFrame({
                    url: "image/btn/btn_icon_recorder",
                    sprite: this.iconSprite
                });
                break;

              case s.NONE:
                this.iconSprite.spriteFrame = null, this.btnLabel.string = "";
                break;

              case s.NORMAL:
                this.iconSprite.spriteFrame = null;
            }
        }
    }, t.prototype.pushEvent = function(t) {
        void 0 === t && (t = this.btnname), h.default.getInstance().sentLog("点击" + this.viewname + "界面" + t + "按键");
    }, a([ y ], t.prototype, "auto", void 0), a([ y ], t.prototype, "tag", void 0), 
    a([ y ], t.prototype, "viewname", void 0), a([ y ], t.prototype, "btnname", void 0), 
    a([ y ], t.prototype, "btnStr", void 0), a([ y({
        type: v,
        displayName: "Btn Bg Type",
        tooltip: "按键背景类型"
    }) ], t.prototype, "btnBgType", void 0), a([ y(cc.Sprite) ], t.prototype, "bgSprite", void 0), 
    a([ y(cc.Sprite) ], t.prototype, "iconSprite", void 0), a([ y(cc.Label) ], t.prototype, "btnLabel", void 0), 
    a([ y ], t.prototype, "btnBgYellowPath", void 0), a([ y ], t.prototype, "btnBgGreenPath", void 0), 
    a([ y ], t.prototype, "btnBgGrayPath", void 0), a([ m ], t);
}(cc.Component);

n.default = w;